package com.lollipop.synthential.algorithm;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @Author: J.K
 * @Date: 2022-07-29 15:19
 * @Description:
 */
public class Server {
    private String IP;

    public Server() {
    }

    public Server(String IP) {
        this.IP = IP;
    }

    public String getIP() {
        return IP;
    }

    public void setIP(String IP) {
        this.IP = IP;
    }

    public String ping() {
        // 生成一个1000~3000之间的随机数
        int random = ThreadLocalRandom.current().nextInt(1000, 2000);
        try {
            // 随机休眠一段时间，模拟不同的响应速度
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 最后返回自身的IP
        return this.IP;
    }
}
